<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const obj = {
        age: 10,
      }
      console.log(obj.age)
      obj.age = 20
      // 监听了obj里面的age属性,
      Object.defineProperty(obj, 'age', {
        get() {
          console.log('获取值')
          return '100'
        },
        set() {},
      })
      obj.age = 1000
      const a = obj.age
      setTimeout(() => {
        obj.age = 100 //
      }, 3000)
    </script>
  </body>
</html>
